创建一个空数组/空对象有哪些方式?

标签:2024-05-19 17:44:13

创建空对象

1.通过字面量: {}

2.通过Object

new Object()

3.通过函数

function a() {
   this.b = 2
}
let c = new a()

4.通过Object.create

Object.create()

创建空数组

1.通过字面量:[]

2.通过Array

new Array()

3.通过Object.create

Object.create(Array.prototype)
原文出处:http://www.dongblog.com/notes/104.html
来源:博客网 转载请注明出处!

活跃用户

雪玉精灵
Ta还没有签名
Ta还没有签名
遗忘
Ta还没有签名
lzy
Ta还没有签名

友情链接


Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093

Warning: Smarty error: unable to read resource: "../../../templates/default/./common/foot/footer_index.htm" in /usr/home/hyu3925200001/htdocs/common/smarty/Smarty.class.php on line 1093